package com.css.zfzx.fwsjcj.modules.analysis.service.impl;

import com.css.zfzx.fwsjcj.commen.util.Constant;
import com.css.zfzx.fwsjcj.modules.analysis.service.SiftAnalysisService;
import com.css.zfzx.fwsjcj.modules.analysis.vo.AnalysisQueryVo;
import com.css.zfzx.fwsjcj.modules.structure.service.FwStructureFormService;
import com.css.zfzx.fwsjcj.modules.taskmanage.taskfrom.service.CityTaskFormService;
import com.css.zfzx.fwsjcj.modules.taskmanage.taskfrom.service.NoCityTaskFromService;
import com.css.zfzx.fwsjcj.modules.taskmanage.taskfrom.service.VillageHouseFormService;
import com.css.zfzx.fwsjcj.modules.taskmanage.taskfrom.service.VillagePubHouseFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author leon
 * @Title: SiftAnalysisServiceImpl
 * @Description: 详查统计分析
 * @date 2020/6/11 19:01
 */
@Service
public class SiftAnalysisServiceImpl implements SiftAnalysisService {
    @Autowired
    private FwStructureFormService structureFormService;
    @Autowired
    private CityTaskFormService cityTaskFormService;
    @Autowired
    private NoCityTaskFromService noCityTaskFromService;
    @Autowired
    private VillageHouseFormService villageHouseFormService;
    @Autowired
    private VillagePubHouseFormService villagePubHouseFormService;

    @Override
    public Map<String, Object> buildingNumData(AnalysisQueryVo analysisQueryVo) {
        // 共10中结构类型 数量
        //砖混结构 砖木结构 多层钢筋混凝土结构 高层结构 工业厂房结构 空旷结构 土木结构 木结构 石结构 其他
        //查询 审批状态 审核通过
        analysisQueryVo.setStatus("审核通过");
        Map<String, Object> map = structureFormService.findbuildCountMap(analysisQueryVo);
        return map;
    }

    @Override
    public Map<String, Object> buildingAreaData(AnalysisQueryVo analysisQueryVo) {
        // 共10中结构类型 数量
        //砖混结构 砖木结构 多层钢筋混凝土结构 高层结构 工业厂房结构 空旷结构 土木结构 木结构 石结构 其他
        analysisQueryVo.setStatus("审核通过");
        Map<String, Object> map = structureFormService.findAreaCountMap(analysisQueryVo);
        return map;
    }

    @Override
    public List<Map> buildingNumDataByBuildingTime(AnalysisQueryVo analysisQueryVo) {
        String[] array = new String[]{"70s以前", "70s", "80s", "90s", "00s", "10s"};
        // 饼数据
        ArrayList<Map> result = new ArrayList<>();
        for (String buildingAge : array) {
            // 设置建筑年代
            analysisQueryVo.setBuildingAge(buildingAge);
            Long count = 0L;
            count = structureFormService.findCount(analysisQueryVo);
            HashMap<String, Object> map = new HashMap<>();
            map.put("value", count);
            map.put("name", buildingAge);
            result.add(map);
        }
        return result;
    }

    @Override
    public List<Map> buildingAreaDataByBuildingTime(AnalysisQueryVo analysisQueryVo) {
        // 年代分类数组
        String[] array = new String[]{"70s以前", "70s", "80s", "90s", "00s", "10s"};
        // 饼数据
        ArrayList<Map> result = new ArrayList<>();
        for (String buildingAge : array) {
            // 设置建筑年代
            analysisQueryVo.setBuildingAge(buildingAge);
            Double areaCount = structureFormService.findAreaCount(analysisQueryVo);
            HashMap<String, Object> map = new HashMap<>();
            map.put("value", areaCount);
            map.put("name", buildingAge);
            result.add(map);
        }
        return result;
    }

    @Override
    public List<Map> buildingNumDataByFortificationIntensity(AnalysisQueryVo analysisQueryVo) {
        // 设防烈度分类数组
        String[] array = new String[]{"未设防", "6度", "7度", "8度", "9度", "10度"};
        // 饼数据
        ArrayList<Map> result = new ArrayList<>();
        for (String nowFortificationIntensity : array) {
            analysisQueryVo.setNowFortificationIntensity(nowFortificationIntensity);
            Long count = 0L;
            count = structureFormService.findCount(analysisQueryVo);
            HashMap<String, Object> map = new HashMap<>();
            map.put("value", count);
            map.put("name", nowFortificationIntensity);
            result.add(map);
        }
        return result;
    }

    @Override
    public List<Map> buildingAreaDataByFortificationIntensity(AnalysisQueryVo analysisQueryVo) {
        // 设防烈度分类数组
        String[] array = new String[]{"未设防", "6度", "7度", "8度", "9度", "10度"};
        // 饼数据
        ArrayList<Map> result = new ArrayList<>();
        for (String nowFortificationIntensity : array) {
            analysisQueryVo.setNowFortificationIntensity(nowFortificationIntensity);
            Double areaCount = structureFormService.findAreaCount(analysisQueryVo);
            HashMap<String, Object> map = new HashMap<>();
            map.put("value", areaCount);
            map.put("name", nowFortificationIntensity);
            result.add(map);
        }
        return result;
    }
}
